<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>非遗百科 - 用户设置</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
            padding: 0;
            margin: 0;
        }
        
        /* 头部导航栏样式 */
        .header {
            background-color: rgb(135, 73, 73);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            padding: 20px 25px;
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 1001;
        }
        
        /* 左侧导航组 */
        .nav-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }
        
        /* 中间主题切换 */
        .nav-center {
            display: flex;
            align-items: center;
            flex: 1;
            justify-content: center;
        }
        
        /* 右侧用户设置 */
        .nav-right {
            display: flex;
            align-items: center;
        }
        
        /* 首页按钮样式 */
        .home-button {
            background-color: rgba(255, 255, 255, 0.2);
            padding: 8px 15px;
            border-radius: 20px;
            margin-right: 15px;
            transition: all 0.3s ease;
        }
        
        .home-button:hover {
            background-color: rgba(255, 255, 255, 0.3);
        }
        
        body.dark-mode .home-button {
            background-color: rgba(255, 255, 255, 0.1);
        }
        
        body.dark-mode .home-button:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }
        
        /* 模式切换按钮样式 */
        .theme-toggle {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #f0f0f0;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            margin-right: 15px;
        }
        
        .theme-toggle:hover {
            background-color: #e0e0e0;
            transform: rotate(15deg);
        }
        
        .theme-toggle svg {
            width: 20px;
            height: 20px;
            fill: #666;
        }
        
        /* 暗色模式样式 */
        body.dark-mode {
            background-color: #1a1a1a;
            color: #e0e0e0;
        }
        
        body.dark-mode .header {
            background-color: #2a2a2a;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        }
        
        body.dark-mode .category-title {
            background-color: #3a3a3a;
            color: #e0e0e0;
        }
        
        body.dark-mode .category-title:hover {
            background-color: #4a4a4a;
        }
        
        body.dark-mode .category-dropdown {
            background-color: #2a2a2a;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        }
        
        body.dark-mode .category-item {
            color: #e0e0e0;
        }
        
        body.dark-mode .category-item:hover {
            background-color: #3a3a3a;
        }
        
        body.dark-mode .user-avatar {
            background-color: #3a3a3a;
        }
        
        body.dark-mode .user-avatar:hover {
            background-color: #4a4a4a;
        }
        
        body.dark-mode .user-avatar.visitor::after {
            color: #999;
        }
        
        /* 类别目录样式 */
        .category-nav {
            position: relative;
            display: flex;
            align-items: center;
        }
        
        .category-title {
            background-color: #f0f0f0;
            padding: 8px 15px;
            border-radius: 20px;
            cursor: pointer;
            font-weight: bold;
            color: #666;
            transition: all 0.3s ease;
            user-select: none;
        }
        
        .category-title:hover {
            background-color: #e0e0e0;
        }
        
        .category-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            margin-top: 10px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            overflow: hidden;
            z-index: 1000;
            display: none;
            min-width: 150px;
        }
        
        .category-nav:hover .category-dropdown {
            display: block;
        }
        
        .category-item {
            padding: 12px 15px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            color: #333;
            white-space: nowrap;
        }
        
        .category-item:hover {
            background-color: #f5f5f5;
        }
        
         
        
        /* 内容容器样式 */
        .content-container {
            max-width: 1200px;
            margin: 20px auto;
            padding: 0 20px;
        }
        
        .content-container h1 {
            margin-bottom: 20px;
            color: #333;
            font-size: 28px;
            text-align: center;
        }
        
        /* 通用内容区块样式 */
        .content-section {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }
        
        body.dark-mode .content-section {
            background-color: #2a2a2a;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        }
        
        /* 设置表单样式 */
        .settings-form {
            max-width: 600px;
            margin: 0 auto;
        }
        
        .settings-group {
            margin-bottom: 25px;
        }
        
        .settings-group label {
            display: block;
            margin-bottom: 10px;
            font-weight: bold;
            color: #333;
        }
        
        body.dark-mode .settings-group label {
            color: #e0e0e0;
        }
        
        .settings-group input[type="text"],
        .settings-group input[type="email"],
        .settings-group input[type="password"],
        .settings-group select,
        .settings-group textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-size: 14px;
            transition: border-color 0.3s ease;
        }
        
        body.dark-mode .settings-group input[type="text"],
        body.dark-mode .settings-group input[type="email"],
        body.dark-mode .settings-group input[type="password"],
        body.dark-mode .settings-group select,
        body.dark-mode .settings-group textarea {
            background-color: #3a3a3a;
            border-color: #555;
            color: #e0e0e0;
        }
        
        .settings-group input:focus,
        .settings-group select:focus,
        .settings-group textarea:focus {
            outline: none;
            border-color: rgb(135, 73, 73);
        }
        
        /* 开关按钮样式 */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 25px;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 25px;
        }
        
        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 19px;
            width: 19px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }
        
        input:checked + .toggle-slider {
            background-color: rgb(135, 73, 73);
        }
        
        input:focus + .toggle-slider {
            box-shadow: 0 0 1px rgb(135, 73, 73);
        }
        
        input:checked + .toggle-slider:before {
            transform: translateX(25px);
        }
        
        /* 设置项样式 */
        .setting-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 0;
            border-bottom: 1px solid #eee;
        }
        
        body.dark-mode .setting-item {
            border-bottom-color: #444;
        }
        
        .setting-item:last-child {
            border-bottom: none;
        }
        
        .setting-label {
            font-weight: bold;
            color: #333;
        }
        
        body.dark-mode .setting-label {
            color: #e0e0e0;
        }
        
        .setting-description {
            font-size: 14px;
            color: #666;
            margin-top: 5px;
        }
        
        body.dark-mode .setting-description {
            color: #999;
        }
        
        /* 按钮样式 */
        .settings-actions {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 30px;
        }
        
        .action-button {
            padding: 10px 25px;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        
        .action-button.save {
            background-color: rgb(135, 73, 73);
            color: white;
        }
        
        .action-button.save:hover {
            background-color: rgb(115, 60, 60);
            transform: translateY(-2px);
        }
        
        .action-button.cancel {
            background-color: #f0f0f0;
            color: #666;
        }
        
        .action-button.cancel:hover {
            background-color: #e0e0e0;
            transform: translateY(-2px);
        }
        
        body.dark-mode .action-button.cancel {
            background-color: #3a3a3a;
            color: #e0e0e0;
        }
        
        body.dark-mode .action-button.cancel:hover {
            background-color: #4a4a4a;
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .header {
                padding: 10px 15px;
            }
            
            .content-container {
                padding: 0 15px;
            }
            
            .content-container h1 {
                font-size: 24px;
            }
        }
        
        @media (max-width: 480px) {
            .header {
                flex-direction: column;
                align-items: stretch;
                gap: 10px;
            }
            
            .category-nav,
            .user-avatar {
                align-self: center;
            }
            
            .content-section {
                padding: 15px;
            }
            
            .settings-actions {
                flex-direction: column;
            }
            
            .action-button {
                width: 100%;
            }
        }
        /* 用户头像样式 */
        .avatar-container {
            position: relative;
            margin-right: 15px;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #f0f0f0;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            overflow: hidden;
        }
        
        .user-avatar:hover {
            transform: scale(1.1);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }
        
        .avatar-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .avatar-menu {
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 10px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            overflow: hidden;
            z-index: 1002;
            display: none;
            min-width: 120px;
        }
        
        .avatar-container:hover .avatar-menu {
            display: block;
        }
        
        .avatar-menu-item {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: #333;
            text-decoration: none;
            transition: background-color 0.3s ease;
        }
        
        .avatar-menu-item:hover {
            background-color: #f5f5f5;
        }
        
        .menu-icon {
            margin-right: 10px;
            font-size: 16px;
        }
        
        .menu-text {
            font-size: 14px;
        }
        
        /* 暗色模式适配 */
        body.dark-mode .user-avatar {
            background-color: #3a3a3a;
        }
        
        body.dark-mode .avatar-menu {
            background-color: #2a2a2a;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        }
        
        body.dark-mode .avatar-menu-item {
            color: #e0e0e0;
        }
        
        body.dark-mode .avatar-menu-item:hover {
            background-color: #3a3a3a;
        }
    </style>
    <script src="assets/js/avatarMenu.js"></script>
</head>
<body>
    <!-- 头部导航栏 -->
    <div class="header">
        <!-- 左侧导航组 -->
        <div class="nav-left">
            <!-- 首页按钮 -->
            <div class="home-button">
                <a href="index.html" style="display: flex; align-items: center; text-decoration: none; color: white;">
                    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" style="margin-right: 5px;">
                        <path d="M12 3L2 12h3v8h6v-6h4v6h6v-8h3L12 3z"/>
                    </svg>
                    <span>首页</span>
                </a>
            </div>
            
            <!-- 类别目录栏 -->
            <div class="category-nav">
                <div class="category-title">非遗类别</div>
                <div class="category-dropdown">
                    <div class="category-item" data-category="传统技艺">传统技艺</div>
                    <div class="category-item" data-category="传统音乐">传统音乐</div>
                    <div class="category-item" data-category="传统舞蹈">传统舞蹈</div>
                    <div class="category-item" data-category="传统戏剧">传统戏剧</div>
                    <div class="category-item" data-category="传统美术">传统美术</div>
                    <div class="category-item" data-category="曲艺">曲艺</div>
                    <div class="category-item" data-category="民间文学">民间文学</div>
                    <div class="category-item" data-category="传统医药">传统医药</div>
                    <div class="category-item" data-category="民俗">民俗</div>
                </div>
            </div>
        </div>
        
        <!-- 中间主题切换 -->
        <div class="nav-center">
            <button class="theme-toggle">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                    <path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/>
                </svg>
            </button>
        </div>
        
        <!-- 右侧用户设置 -->
        <div class="nav-right">
            <!-- 用户头像功能已移除 -->
        </div>
    </div>

    <!-- 主内容区域 -->
    <div class="content-container">
        <h1>用户设置</h1>
        
        <!-- 基本设置 -->
        <div class="content-section">
            <h2>基本设置</h2>
            <div class="setting-item">
                <div>
                    <div class="setting-label">深色模式</div>
                    <div class="setting-description">启用后切换为深色主题显示</div>
                </div>
                <label class="toggle-switch">
                    <input type="checkbox" id="dark-mode-toggle">
                    <span class="toggle-slider"></span>
                </label>
            </div>
            
            <div class="setting-item">
                <div>
                    <div class="setting-label">自动加载更多</div>
                    <div class="setting-description">滚动到底部时自动加载更多内容</div>
                </div>
                <label class="toggle-switch">
                    <input type="checkbox" id="auto-load-toggle" checked>
                    <span class="toggle-slider"></span>
                </label>
            </div>
            
            <div class="setting-item">
                <div>
                    <div class="setting-label">保存搜索历史</div>
                    <div class="setting-description">记录您的搜索关键词以便快速访问</div>
                </div>
                <label class="toggle-switch">
                    <input type="checkbox" id="save-history-toggle" checked>
                    <span class="toggle-slider"></span>
                </label>
            </div>
        </div>
        
        <!-- 通知设置 -->
        <div class="content-section">
            <h2>通知设置</h2>
            <div class="setting-item">
                <div>
                    <div class="setting-label">新内容通知</div>
                    <div class="setting-description">当有新的非遗项目添加时通知您</div>
                </div>
                <label class="toggle-switch">
                    <input type="checkbox" id="new-content-toggle">
                    <span class="toggle-slider"></span>
                </label>
            </div>
            
            <div class="setting-item">
                <div>
                    <div class="setting-label">活动通知</div>
                    <div class="setting-description">接收与非遗相关的活动和展览通知</div>
                </div>
                <label class="toggle-switch">
                    <input type="checkbox" id="event-toggle">
                    <span class="toggle-slider"></span>
                </label>
            </div>
        </div>
        
        <!-- 账户安全 -->
        <div class="content-section">
            <h2>账户安全</h2>
            <div class="setting-item">
                <div>
                    <div class="setting-label">修改密码</div>
                    <div class="setting-description">定期修改密码以保护账户安全</div>
                </div>
                <button class="action-button cancel" id="change-password-button">修改</button>
            </div>
            
            <div class="setting-item">
                <div>
                    <div class="setting-label">隐私设置</div>
                    <div class="setting-description">管理您的个人信息和浏览记录</div>
                </div>
                <button class="action-button cancel" id="privacy-button">管理</button>
            </div>
        </div>
        
        <!-- 操作按钮 -->
        <div class="settings-actions">
            <button class="action-button save" id="save-button">保存设置</button>
            <button class="action-button cancel" id="cancel-button">返回首页</button>
        </div>
    </div>

    <script>
        // 类别目录栏点击事件处理
        document.querySelectorAll('.category-item').forEach(item => {
            item.addEventListener('click', function() {
                const category = this.getAttribute('data-category');
                window.location.href = `category.html?type=${encodeURIComponent(category)}`;
            });
        });
        
         
        
        // 为页面标题添加点击事件，跳转到首页
        document.querySelector('h1').addEventListener('click', function() {
            window.location.href = 'waterfall.html';
        });
        
        // 模式切换功能
        function setupThemeToggle() {
            const themeToggle = document.querySelector('.theme-toggle');
            const body = document.body;
            const darkModeSettingToggle = document.getElementById('dark-mode-toggle');
            
            // 检查用户之前的主题偏好
            if (localStorage.getItem('theme') === 'dark' || 
                (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
                body.classList.add('dark-mode');
                darkModeSettingToggle.checked = true;
            } else {
                body.classList.remove('dark-mode');
                darkModeSettingToggle.checked = false;
            }
            
            // 添加点击事件处理
            themeToggle.addEventListener('click', function() {
                body.classList.toggle('dark-mode');
                darkModeSettingToggle.checked = body.classList.contains('dark-mode');
                
                // 保存用户的主题偏好
                if (body.classList.contains('dark-mode')) {
                    localStorage.setItem('theme', 'dark');
                } else {
                    localStorage.setItem('theme', 'light');
                }
            });
            
            // 监听设置中的深色模式切换
            darkModeSettingToggle.addEventListener('change', function() {
                if (this.checked) {
                    body.classList.add('dark-mode');
                    localStorage.setItem('theme', 'dark');
                } else {
                    body.classList.remove('dark-mode');
                    localStorage.setItem('theme', 'light');
                }
            });
        }
        
        // 初始化其他设置
        function loadUserSettings() {
            // 检查是否存在保存的设置，如果有则加载
            const autoLoadEnabled = localStorage.getItem('autoLoadEnabled') !== 'false';
            const saveHistoryEnabled = localStorage.getItem('saveHistoryEnabled') !== 'false';
            const newContentNotifications = localStorage.getItem('newContentNotifications') === 'true';
            const eventNotifications = localStorage.getItem('eventNotifications') === 'true';
            
            // 应用保存的设置
            document.getElementById('auto-load-toggle').checked = autoLoadEnabled;
            document.getElementById('save-history-toggle').checked = saveHistoryEnabled;
            document.getElementById('new-content-toggle').checked = newContentNotifications;
            document.getElementById('event-toggle').checked = eventNotifications;
        }
        
        // 保存用户设置
        function saveUserSettings() {
            const autoLoadEnabled = document.getElementById('auto-load-toggle').checked;
            const saveHistoryEnabled = document.getElementById('save-history-toggle').checked;
            const newContentNotifications = document.getElementById('new-content-toggle').checked;
            const eventNotifications = document.getElementById('event-toggle').checked;
            
            // 保存设置到本地存储
            localStorage.setItem('autoLoadEnabled', autoLoadEnabled);
            localStorage.setItem('saveHistoryEnabled', saveHistoryEnabled);
            localStorage.setItem('newContentNotifications', newContentNotifications);
            localStorage.setItem('eventNotifications', eventNotifications);
            
            // 显示保存成功提示
            alert('设置已保存');
        }
        
        // 设置按钮点击事件
        function setupButtonEvents() {
            const saveButton = document.getElementById('save-button');
            const cancelButton = document.getElementById('cancel-button');
            const changePasswordButton = document.getElementById('change-password-button');
            const privacyButton = document.getElementById('privacy-button');
            
            saveButton.addEventListener('click', saveUserSettings);
            
            cancelButton.addEventListener('click', function() {
                window.location.href = 'waterfall.html';
            });
            
            changePasswordButton.addEventListener('click', function() {
                // 预留页面跳转链接位置
                // window.location.href = 'change-password.html';
                alert('即将跳转到修改密码页面');
            });
            
            privacyButton.addEventListener('click', function() {
                // 预留页面跳转链接位置
                // window.location.href = 'privacy-settings.html';
                alert('即将跳转到隐私设置页面');
            });
        }
        
        // 页面加载完成后初始化
        document.addEventListener('DOMContentLoaded', function() {
            setupThemeToggle();
            loadUserSettings();
            setupButtonEvents();
        });
    </script>
</body>
</html>